
#include "worker.h"
#include "mainwindow.h"

Worker::Worker() :
    mutex(),
    cmd_stop(false),
    stopping(false)
   {

}

void Worker::DoWork(MainWindow* caller) {
     {
        boost::lock_guard<boost::mutex> lock(mutex);
        PlotData = Gtk :: make_managed<PlotData2D>(Gdk::RGBA("red"),CONTINUOUS,1.0,"1");
        PlotData1 = Gtk :: make_managed<PlotData2D>(Gdk::RGBA("green"),CONTINUOUS,1.0,"2");
        stopping = false;
    }                                                                   //разблокировка мъютекса
float y1,x1=0;
unsigned long long x2;
boost::random::mt19937 rng;
boost::random::uniform_int_distribution<> six(-100,200);



for (int i = 0; i < 400; ++i) {
        x2=i;
        this->PlotData1->AddDataToX(x2);
        y1=sin(x1);
       this->PlotData1->AddDataToY(y1);
        x1=x1+0.1;
    }

    for (int i = 0; i < 400; ++i) {
        this->PlotData->AddDataToX(i);
        y1=six(rng);
        this->PlotData->AddDataToY(y1);
    }

    caller->Notify();
    while (!cmd_stop) {}

}

 PlotData2D* Worker::GetPlotData()
 {
     return PlotData;
}
 PlotData2D* Worker::GetPlotData1()
 {
     return PlotData1;
}
void Worker::set_manage() {
         m_managed = true;
       }

    void Worker::  print(){
              std::cout << "Done..." << std::endl;
        }
